﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using mfXmlSerializer.TestObjects;

namespace mfXmlSerializer.NetduinoPlus2.TestApp
{
    /// <summary>
    /// all required externals are in SOURCE CODE in project: 'mfXmlSerializer.NetduinoPlus2.TestApp'
    /// </summary>
    public class Program
    {
        public static void Main()
        {
            /*
            #############################################################
            para : Parameter =
            Version: some v1.0 | Number: 48 | FloatNumber: 48.479999999999997 | Created: 01/12/2014 13:12:00 | Logging.FileLoggingActive: True | Logging.TraceLevel: 1
            #############################################################
            serialization done within 10 ms
            paraXmlString : String =
            <?xml version="1.0" encoding="utf-8"?>
            <Parameter>
                <Version>some v1.0</Version>
                <Number>48</Number>
                <FloatNumber>48.479999999999997</FloatNumber>
                <Created>01/12/2014 13:12:00</Created>
                <Logging>
                  <TraceLevel>1</TraceLevel>
                  <FileLoggingActive>True</FileLoggingActive>
                </Logging>
             </Parameter>
            #############################################################
            deserialization done within 59 ms
            deserializedPara : Parameter =
            Version: some v1.0 | Number: 48 | FloatNumber: 48.479999999999997 | Created: 01/12/2014 13:12:00 | Logging.FileLoggingActive: True | Logging.TraceLevel: 1
            #############################################################
            */

            var para = new Parameter() { Version = "some v1.0", Number = 48, FloatNumber = 48.48, Created = new DateTime(2014, 1, 12, 13, 12, 00) };
            para.Logging.FileLoggingActive = true;
            para.Logging.TraceLevel = enumTraceLevel.Debug;

            var paraSerializer = new mfXmlSerializer(para.GetType());

            //serialization
            var paraXmlString = paraSerializer.Serialize(para);

            //deserialization
            var deserializedPara = paraSerializer.Deserialize(paraXmlString);

            //TODO: do some cool stuff with deserialized object
        }
    }
}